home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 1.iso / dist / fw_ispell.idb / usr / freeware / bin / tryaffix.z / tryaffix (.txt)
Microsoft Windows Help File Content  |  2000-01-25  |  4KB  |  107 lines

  1. : Use /bin/sh
  2. # $Id: tryaffix.X,v 1.6 1994/01/25 07:12:18 geoff Exp $
  3. # Copyright 1987, 1988, 1989, 1992, 1993, Geoff Kuenning, Granada Hills, CA
  4. # All rights reserved.
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. # 1. Redistributions of source code must retain the above copyright
  9. #    notice, this list of conditions and the following disclaimer.
  10. # 2. Redistributions in binary form must reproduce the above copyright
  11. #    notice, this list of conditions and the following disclaimer in the
  12. #    documentation and/or other materials provided with the distribution.
  13. # 3. All modifications to the source code must be clearly marked as
  14. #    such.  Binary redistributions based on modified source code
  15. #    must be clearly marked as modified versions in the documentation
  16. #    and/or other materials provided with the distribution.
  17. # 4. All advertising materials mentioning features or use of this software
  18. #    must display the following acknowledgment:
  19. #      This product includes software developed by Geoff Kuenning and
  20. #      other unpaid contributors.
  21. # 5. The name of Geoff Kuenning may not be used to endorse or promote
  22. #    products derived from this software without specific prior
  23. #    written permission.
  24. # THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
  25. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. # ARE DISCLAIMED.  IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
  28. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  30. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  31. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  33. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. # SUCH DAMAGE.
  35. # Try out affixes to see if they produce valid roots
  36. # Usage:
  37. #    tryaffix [-p | -s] [-c] dict-file affix[+addition] ...
  38. #    The -p and -s flags specify whether prefixes or suffixes
  39. #    are being tried;  if neither is specified, suffixes are assumed.
  40. #    If the -c flag is given, statistics on the various affixes are given:
  41. #    a count of words it potentially applies to, and an estimate of the
  42. #    number of dictionary bytes the flag would save.  The estimate will
  43. #    be high if the flag generates words that are currently generated
  44. #    by other flags.
  45. #    The dictionary file, dict-file, must already be expanded and sorted,
  46. #    and things will work best if uppercase has been folded to lower with
  47. #    'tr'.
  48. #    The "affixes" are things to be stripped from the dictionary
  49. #    file to produce trial roots:  for English, "con" and "ing"
  50. #    are examples.  The "additions" are letters that would have
  51. #    been stripped off the root before adding the affix.  For
  52. #    example, the affix "ing" strips "e" for words ending in "e"
  53. #    (as in "like --> liking") so we might run:
  54. #        tryaffix ing ing+e
  55. #    to cover both cases.
  56. # $Log: tryaffix.X,v $
  57. # Revision 1.6  1994/01/25  07:12:18  geoff
  58. # Get rid of all old RCS log lines in preparation for the 3.1 release.
  59. SORTTMP="-T ${TMPDIR-/usr/tmp}"        # !!SORTTMP!!
  60. USAGE='tryaffix [-p | -s] [-c] dict-file affix[+addition] ...'
  61. counts=no
  62. suf='$'
  63. while :
  64.     case "$1" in
  65.         pre='^'
  66.         suf=
  67.         ;;
  68.         pre=
  69.         suf='$'
  70.         ;;
  71.         counts=yes
  72.         ;;
  73.         echo "$USAGE" 1>&2
  74.         exit 1
  75.         ;;
  76.         break
  77.         ;;
  78.     esac
  79.     shift
  80. dict="$1"
  81. shift
  82. if [ ! -r "$dict" ]
  83.     echo "Can't read $dict" 1>&2
  84.     echo "$USAGE" 1>&2
  85.     exit 1
  86. elif [ $# -eq 0 ]
  87.     echo "$USAGE" 1>&2
  88.     exit 1
  89. while [ $# -ne 0 ]
  90.     case "$1" in
  91.     *+*)
  92.         affix=`expr "$1" : '\(.*\)+'`
  93.         addition=`expr "$1" : '.*+\(.*\)'`
  94.         sedscript="s/$pre$affix$suf/$addition/p"
  95.         ;;
  96.         sedscript="s/$pre$1$suf//p"
  97.         ;;
  98.     esac
  99.     if [ "$counts" = no ]
  100.     then
  101.     echo ===== "$1" =====
  102.     sed -n "$sedscript" "$dict" | comm -12 - "$dict"
  103.     else
  104.     echo "$1" `sed -n "$sedscript" "$dict" | comm -12 - "$dict" | wc -lc`
  105.     fi
  106.     shift
  107.